//
//  ConnectWithTableViewCell.m
//  Choose_to_do_title
//
//  Created by seven on 16/4/13.
//  Copyright © 2016年 QC. All rights reserved.
//

#import "ConnectWithTableViewCell.h"
#import "LongTermInsurance-Swift.h"
@implementation ConnectWithTableViewCell

- (void)awakeFromNib{
    [super awakeFromNib];
    self.selectionStyle = UITableViewCellSelectionStyleNone;

}

- (void)setModel:(SurveyModel *)model{
    _model = model;
    
    self.questionTitle.text = self.model.title;
    if (self.model.surveyArray.count >= 1) {
        self.answerOne.text = self.model.surveyArray[0].itemName;
    }
    if (self.model.surveyArray.count >= 2) {
        self.answerTwo.text = self.model.surveyArray[1].itemName;
    }
    if (self.model.surveyArray.count >= 3) {
        self.answerThree.text = self.model.surveyArray[2].itemName;
    }
    if (self.model.surveyArray.count >= 4) {
        self.answerFour.text = self.model.surveyArray[3].itemName;
    }
    
    self.answerBtnOne.enabled = self.answerOne.text.length;
    self.answerBtnTwo.enabled = self.answerTwo.text.length;
    self.answerBtnThree.enabled = self.answerThree.text.length;
    self.answerBtnFour.enabled = self.answerFour.text.length;
    [self setMark:model.selectIndex];
}

//-(void)setModel:(ConnectModel *)model
//{
//    _model = model;
//
//    self.questionTitle.text = self.model.title;
//    self.answerOne.text = self.model.one;
//    self.answerTwo.text = self.model.two;
//    self.answerThree.text = self.model.three;
//    self.answerFour.text = self.model.four;
//
//    //    self.answerOne.hidden = !self.model.one.length;
//    //    self.answerTwo.hidden = !self.model.two.length;
//    //    self.answerThree.hidden = !self.model.three.length;
//    //    self.answerFour.hidden = !self.model.four.length;
//
//    self.answerBtnOne.enabled = self.model.one.length;
//    self.answerBtnTwo.enabled = self.model.two.length;
//    self.answerBtnThree.enabled = self.model.three.length;
//    self.answerBtnFour.enabled = self.model.four.length;
//    [self setMark:model.selectIndex];
//}

- (IBAction)answerButton:(UIButton *)sender {
    self.answerBtnOne.selected = NO;
    self.answerBtnTwo.selected = NO;
    self.answerBtnThree.selected = NO;
    self.answerBtnFour.selected = NO;
    sender.selected = YES;
    self.model.selectIndex = sender.tag;
    
    if (self.block) {
        self.block();
    }
}

- (void)setMark:(NSInteger )mark
{
    self.answerBtnOne.selected = NO;
    self.answerBtnTwo.selected = NO;
    self.answerBtnThree.selected = NO;
    self.answerBtnFour.selected = NO;
    if (mark == 0) {
        
    } else if (mark == 1) {
        self.answerBtnOne.selected = YES;
    } else if (mark == 2) {
        self.answerBtnTwo.selected = YES;
    } else if (mark == 3) {
        self.answerBtnThree.selected = YES;
    } else {
        self.answerBtnFour.selected = YES;
    }
}



@end
